package com.loadmore.baselibrary.widget;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;

import com.loadmore.baselibrary.util.LogUtil;

/**
 * Created by sunleilei on 2017/3/15
 */

public class NoScrollViewpager extends ViewPager {

    private boolean forbit;
    public NoScrollViewpager(Context context) {
        super(context);
    }

    public NoScrollViewpager(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public void setScroll(boolean forbit) {
        this.forbit = forbit;
    }

    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        LogUtil.e( getClass().getCanonicalName()+"    >>>>>>>    onTouchEvent");
        return super.onTouchEvent(ev);
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        LogUtil.e(getClass().getCanonicalName()+"   >>>>>>>  dispatchTouchEvent");
        if (forbit) {
            return true;
        }
        return super.dispatchTouchEvent(ev);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        LogUtil.e(getClass().getCanonicalName()+"onInterceptTouchEvent");
        return super.onInterceptTouchEvent(ev);
    }
}
